package com.atung.provider;

import java.util.Objects;

import org.apache.ibatis.jdbc.SQL;

import com.atung.model.BusSchoolUser;

public class BusSchoolUserProvider {

	public String insertUserProvide(BusSchoolUser busSchoolUser){
		
		return new SQL(){{
			  INSERT_INTO("bus_school_user");
//              VALUES("id","#{id}");
              VALUES("open_id","#{openId}");
              if(Objects.nonNull(busSchoolUser.getUserName())){
            	  VALUES("user_name","#{userName}");
              }
             if(Objects.nonNull(busSchoolUser.getSchoolName())){
            	 VALUES("school_name","#{schoolName}");
             }
             if(Objects.nonNull(busSchoolUser.getSchoolId())){
            	 VALUES("school_id","#{schoolId}");
             }
             if(Objects.nonNull(busSchoolUser.getUserPhone())){
                 VALUES("user_phone","#{userPhone}");
             }
             if(Objects.nonNull(busSchoolUser.getUserSex())){
                 VALUES("user_sex","#{userSex}");
             }
             if(Objects.nonNull(busSchoolUser.getWxName())){
                 VALUES("wx_name","#{wxName}");
             }
             if(Objects.nonNull(busSchoolUser.getWxPhoto())){
                 VALUES("wx_photo","#{wxPhoto}");
             }
             if(Objects.nonNull(busSchoolUser.getIsDelect())){
                 VALUES("is_delect","#{isDelect}");
             }
             if(Objects.nonNull(busSchoolUser.getCreationTime())){
            	 VALUES("creation_time","#{creationTime}");
             }
             if(Objects.nonNull(busSchoolUser.getModificationTime())){
            	  VALUES("modification_time","#{modificationTime}");
             }
		}
		}.toString();
	}
	public String updateUserProvide(BusSchoolUser busSchoolUser){
		
		return new SQL(){{
			  UPDATE("bus_school_user");
          
              if(Objects.nonNull(busSchoolUser.getUserName())){
            	  SET("user_name=#{userName}");
              }
             if(Objects.nonNull(busSchoolUser.getSchoolName())){
            	 SET("school_name=#{schoolName}");
             }
             if(Objects.nonNull(busSchoolUser.getSchoolId())){
            	 SET("school_id=#{schoolId}");
             }
             if(Objects.nonNull(busSchoolUser.getUserPhone())){
            	 SET("user_phone=#{userPhone}");
             }
             if(Objects.nonNull(busSchoolUser.getUserSex())){
            	 SET("user_sex=#{userSex}");
             }
             if(Objects.nonNull(busSchoolUser.getWxName())){
            	 SET("wx_name=#{wxName}");
             }
             if(Objects.nonNull(busSchoolUser.getWxPhoto())){
            	 SET("wx_photo=#{wxPhoto}");
             }
             if(Objects.nonNull(busSchoolUser.getIsDelect())){
            	 SET("is_delect=#{isDelect}");
             }
             if(Objects.nonNull(busSchoolUser.getCreationTime())){
            	 SET("creation_time=#{creationTime}");
             }
             if(Objects.nonNull(busSchoolUser.getModificationTime())){
            	 SET("modification_time=#{modificationTime}");
             }
             WHERE("open_id=#{openId}");
		}
		}.toString();
	}
	
}
